package rs.dalao.syc.user.all.dao.persist.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import rs.dalao.syc.user.all.dao.persist.mapper.IUserMapper;
import rs.dalao.syc.user.all.dao.persist.mapper.IUserPersonalMapper;
import rs.dalao.syc.user.all.dao.persist.repository.IUserPersonalRepository;
import rs.dalao.syc.user.all.pojo.entity.User;
import rs.dalao.syc.user.all.pojo.entity.UserPersonal;
import rs.dalao.syc.user.all.pojo.vo.UserPersonalListVO;

@Repository
public class UserPersonalRepositoryImpl implements IUserPersonalRepository {
    @Autowired
    private IUserPersonalMapper iUserPersonalMapper;

    @Autowired
    private IUserMapper userMapper;

    //根据查看用户真实信息是否存在
    @Override
    public  UserPersonal selectByUserId(Long id) {
        UserPersonal userPersonal = iUserPersonalMapper.selectById(id);
        return userPersonal;
    }

    //添加用户真实信息
    @Override
    public int insert(UserPersonal userPersonal) {
        return iUserPersonalMapper.insert(userPersonal);
    }

    //修改发用户的真实信息
    @Override
    public int updateByUserId(UserPersonal userPersonal) {
        return iUserPersonalMapper.updateByUserId(userPersonal);
    }

    @Override
    public UserPersonalListVO selectInfoById(Long id) {
        return iUserPersonalMapper.selectInfoById(id);
    }

    @Override
    public int updateRoleById(Long id) {
        User user=new User();
        user.setId(id);
        user.setRole(2l);
        return userMapper.updateById(user);
    }

}
